package com.gasolinator.a.app.adapter;

import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.gasolinator.a.R;
import com.gasolinator.a.app.GasolinatorTypes;

/**
 * Created by IntelliJ IDEA.
 * User: fjhidalgo
 * Date: 24/03/12
 * Time: 12:26
 * To change this template use File | Settings | File Templates.
 */
public class SpinnerViewSimpleBinder implements SimpleAdapter.ViewBinder
{
    public boolean setViewValue(View view, Object o, String s)
    {
//        Map<String, String> data = (Map<String, String>) o;
//
//        Log.i("========: name =:",data.get("name"));
//        Log.i("========: _id =:",data.get("_id"));
        Log.i("========: o =:", o.toString());

        int viewId = view.getId();
        switch (viewId) {
            case R.id.TextSpinner:
                TextView mView = (TextView) view;
                mView.setText(s);
                break;

            case R.id.BrandLogoSpinner:
                // the icon
                ImageView mIconView = (ImageView) view;
                byte type = GasolinatorTypes.getResourceByName(s);
                int resource = GasolinatorTypes.getImageResource(type);
                mIconView.setImageResource(resource);
        }
        return true;
    }
}
